use std::io;
use rand::Rng;
use std::cmp::Ordering;

fn main() {
    println!("Guess the number!");
    println!("Please input your guess:");
    let mut guess=String::new();//可变变量 mut
    let num=rand::thread_rng().gen_range(1,100);
    io::stdin().read_line(&mut guess)    
    .expect("Fail to read line");
    let guess:u32=guess.trim().parse()
    .expect("Please type a number");
    println!("you guessed: {} the key: {}",guess,num);
    match guess.cmp(&num){
        Ordering::Less=>println!("Small"),
        Ordering::Greater=>println!("Big"),
        Ordering::Equal=>println!("Win"),
    }
}
